package com.jt.controller;

import com.jt.pojo.Course;
import com.jt.service.CourseService;
import com.jt.vo.CourseVO;
import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @GetMapping("/getCourseList")
    public SysResult getCourseList(PageResult pageResult){
        pageResult = courseService.getCourseList(pageResult);
        return SysResult.success(pageResult);//5
    }

    /**
     * 修改状态
     */
    @PutMapping("/updateCourseStatus")
    public SysResult updateCourseStatus(@RequestBody Course course){
        courseService.updateCourseStatus(course);
        return SysResult.success();
    }

    /**
     * 删除
     */
    @DeleteMapping("/deleteCourseById")
    public SysResult deleteCourseById(Course course){
        courseService.deleteCourseById(course);
        return SysResult.success();
    }

    /**
     * 修改
     * @param course
     * @return
     */
    @PutMapping("/updateCourseById")
    public SysResult updateCourseById(@RequestBody Course course){
        courseService.updateCourseById(course);
        return SysResult.success();
    }

    /**
     * 新增
     */
    @PostMapping("/saveCourse")
    public SysResult saveCourse(@RequestBody CourseVO courseVO){
        courseService.saveCourse(courseVO);
        return SysResult.success();
    }



}
